package com.photopicker.util;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

public class ToastUtils {
	
	private static Toast mToast;
	
	/**
	 * 显示Toast
	 */
	public static void showToast(Context context, CharSequence text, int duration) {
		if(mToast == null) {
			mToast = Toast.makeText(context, text, duration);
		} else {
			mToast.setText(text);
			mToast.setDuration(duration);
		}
		mToast.setGravity(Gravity.CENTER, 0, 10);
		mToast.show();
	}

	/** 短暂显示Toast提示(来自res) **/
	protected void showShortToast(Context context,int resId) {
		if (mToast != null) {
			mToast.setText(resId);
			mToast.setDuration(Toast.LENGTH_SHORT);
		} else {
			mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
		}
		mToast.show();
	}
}
